<template>
  <div id="app">
    <div class="handbox">
      <button
        v-for="(i, index) in buttonlist"
        :key="index"
        :class="{ active: i.check }"
        @click="linkto(i)"
      >
        {{ i.name }}
        <!-- <router-link :to="i.path">{{i.name}}</router-link> -->
      </button>
    </div>
    <div class="box">
      <router-view />
    </div>
  </div>
</template>
<script>
export default {
  name: "App",
  data() {
    return {
      buttonlist: [
        {
          name: "openleayers",
          check: true,
          path: "/openleayers",
        },
        {
          name: "mapbox",
          check: false,
          path: "/mapbox",
        },
        {
          name: "思极地图",
          check: false,
          path: "/siji",
        },
        {
          name: "cesium",
          check: false,
          path: "/cesium",
        },
        {
          name: "mapbox1",
          check: false,
          path: "/mapbox1",
        },
      ],
    };
  },
  methods: {
    linkto(i) {
      this.buttonlist.forEach((item) => {
        item.check = false;
      });
      i.check = true;
      this.$router.push({ path: i.path });
    },
  },
};
</script>
<style lang="less">
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  width: 100vw;
  height: 100vh;
  box-sizing: border-box;
}
.handbox {
  width: 100%;
  height: 40px;
  // border: 1px solid red;
  box-sizing: border-box;
  display: flex;
  justify-content: flex-start;
  button {
    margin-left: 10px;
  }
  .active {
    background: red;
  }
  padding: 4px;
}
.box {
  width: 100vw;
  height: calc(100vh - 40px);
  // border: 1px solid red;
  box-sizing: border-box;
}
</style>
